﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_Flow_DeleteJump_V2]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_Flow_DeleteJump_V2];
GO
CREATE PROCEDURE [dbo].[sproc_Flow_DeleteJump_V2]
    @FlowID int,
    @StepID int,
    @Priority int
AS
BEGIN
SET NOCOUNT ON;
SET XACT_ABORT ON;

BEGIN TRANSACTION;

DELETE FROM dbo.uds_flow_jump WHERE flow_id = @flowid and step_id = @stepid and priority = @priority;

UPDATE dbo.uds_flow_jump
    SET priority = priority - 1
    WHERE
        flow_id = @flowid
        and step_id = @stepid
        and priority > @priority

COMMIT TRANSACTION;
RETURN 0;

END
GO
